﻿using Cngot.Extensions.EventBus.RabbitMQ;
using Cngot.Extensions.EventBus.RabbitMQ.Integration;
using System;
using System.Threading.Tasks;

namespace WebApi.Consumer
{
    [MessageSubscribe("direct1", null, RabbitExchangeType.Direct, instance: "rabbit")]
    public class RabbitConsumerListener : IRabbitConsumerListener
    {
        public Task HandleAsync(RecieveResult recieveResult)
        {
            Console.WriteLine("RabbitConsumerListener:" + recieveResult.Body);
            recieveResult.Commit();
            //result.RollBack();//回滚，参数表示是否重新消费
            return Task.CompletedTask;
        }
    }

    [MessageSubscribe("direct1", null, RabbitExchangeType.Direct, instance: "rabbit")]
    public class RabbitConsumerListener2 : IRabbitConsumerListener
    {
        public Task HandleAsync(RecieveResult recieveResult)
        {
            Console.WriteLine("RabbitConsumerListener2:" + recieveResult.Body);
            recieveResult.Commit();
            //result.RollBack();//回滚，参数表示是否重新消费
            return Task.CompletedTask;
        }
    }
}
